Release 10.1A: OpenEdge Data Management:
SQL Development
Working with tables
The following sections provide details on creating, modifying, and deleting tables.
Using the CREATE TABLE statement
The
CREATE TABLEstatement allows you to create a new table in an existing database by defining its column names and column data types. Optionally, you can include table and column constraints.The
CREATE TABLEstatement uses the following syntax:
Example 5–1 illustrates a
CREATE TABLEstatement. Thecust_nocolumn has the column constraintNOT NULL, which indicates that no row in the customer table is to have aNULLvalue in thecust_nocolumn.
The
CREATE TABLEstatement also allows you to specify theDEFAULTclause along with a column definition. TheDEFAULTclause identifies the default value to be used for a column.The default clause uses the following syntax:
The following
CREATE TABLEstatement shows how to use theDEFAULTclause. Example 5–2 sets a default value of 10 for thedeptnocolumn.
For more information on the
CREATE TABLEstatement and theDEFAULTclause, see OpenEdge Data Management: SQL Reference .ALTER TABLE
The
Note: For a complete description of theALTER TABLEstatement lets you add new columns to a table, delete columns from a table, or change the format and labels associated with an existing column.ALTER TABLEsyntax, see OpenEdge Data Management: SQL Reference .The
ALTER TABLEstatement has the following syntax:
The addition or deletion of columns is a common modification for tables. When a column is added, the OpenEdge RDBMS places the column to the far right of the table. Unless you declare the column to be
NOT NULLand assign a default value, the RDBMS will assume the column has a value ofNULLfor each row in the existing table.Example 5–3 shows how the
ALTER TABLEstatement is used to add a column to a table.
The
ALTER TABLEstatement also can be used to change the name of an existing table. To do so, SQL uses the following syntax:
Example 5–4 shows how the
ALTER TABLEstatement is used to rename an existing table.
DROP TABLE
The
DROP TABLEstatement deletes all data and indexes for a table and erases its entry in the system catalog. TheDROP TABLEstatement uses the following syntax:
Example 5–5 illustrates the use of a
DROP TABLEstatement.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |